import java.util.Scanner;

public class NarcissisticNumberChecker2 {
    public static void main(String[] args) {
        System.out.println(isNarcissisticNumber(153));  // 输出: true
        System.out.println(isNarcissisticNumber(370));  // 输出: true

        //自己输入
        Scanner scanner = new Scanner(System.in);
 
        System.out.print("请输入一个三位数： ");
        int shu = scanner.nextInt();

         System.out.println(isNarcissisticNumber(shu));

    }


    public static boolean isNarcissisticNumber(int num) {
        if (num < 100 || num > 999) {
            return false;
        }

        String numStr = Integer.toString(num);
        int numLen = numStr.length();
        int sumOfCubes = 0;

        for (int i = 0; i < numLen; i++) {
            int digit = Character.getNumericValue(numStr.charAt(i));
            sumOfCubes += Math.pow(digit, numLen);
        }

        return num == sumOfCubes;
    }
}